import { createApp } from "vue";
import App from "./App.vue";
import { setupStore } from "./store";

import naive from "naive-ui";
import { setupRouter } from "@/router";
import NaiveProvider from "@/components/NaiveProvider/NaiveProvider.vue";

async function setupApp() {
  const appProvider = createApp(NaiveProvider);

  const app = createApp(App);

  app.use(naive);

  // 挂载状态管理.
  setupStore(app);

  // 优先挂载Provider, 路由, 页面跳转等会使用到Dialog、Message等组件
  appProvider.mount("#appProvider", true);

  // 挂载路由
  await setupRouter(app);

  app.mount("#app", true);
}

void setupApp();
